package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.MstnProjectConditionMapper;
import com.ruoyi.system.domain.MstnProjectCondition;
import com.ruoyi.system.service.IMstnProjectConditionService;

/**
 * 项目条件Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-07-18
 */
@Service
public class MstnProjectConditionServiceImpl implements IMstnProjectConditionService 
{
    @Autowired
    private MstnProjectConditionMapper mstnProjectConditionMapper;

    /**
     * 查询项目条件
     * 
     * @param projectConditionId 项目条件主键
     * @return 项目条件
     */
    @Override
    public MstnProjectCondition selectMstnProjectConditionByProjectConditionId(Long projectConditionId)
    {
        return mstnProjectConditionMapper.selectMstnProjectConditionByProjectConditionId(projectConditionId);
    }

    /**
     * 查询项目条件列表
     * 
     * @param mstnProjectCondition 项目条件
     * @return 项目条件
     */
    @Override
    public List<MstnProjectCondition> selectMstnProjectConditionList(MstnProjectCondition mstnProjectCondition)
    {
        return mstnProjectConditionMapper.selectMstnProjectConditionList(mstnProjectCondition);
    }

    /**
     * 查询项目条件列表
     *
     * @param projectId 项目id
     * @return 项目条件集合
     */
    @Override
    public List<MstnProjectCondition> selectMstnProjectConditionListByProjectId(Long projectId){
        return mstnProjectConditionMapper.selectMstnProjectConditionListByProjectId(projectId);
    }

    /**
     * 校验条件是否已添加
     * @param projectId
     * @param conditionType
     * @return
     */
    @Override
    public boolean checkProjectCondition(Long projectId, String conditionType ){
        MstnProjectCondition condition = new MstnProjectCondition();
        condition.setConditionType(conditionType);
        condition.setProjectId(projectId);
        return mstnProjectConditionMapper.selectMstnProjectConditionList(condition).isEmpty();
    }
    /**
     * 新增项目条件
     * 
     * @param mstnProjectCondition 项目条件
     * @return 结果
     */
    @Override
    public int insertMstnProjectCondition(MstnProjectCondition mstnProjectCondition)
    {
        mstnProjectCondition.setCreateTime(DateUtils.getNowDate());
        return mstnProjectConditionMapper.insertMstnProjectCondition(mstnProjectCondition);
    }

    /**
     * 修改项目条件
     * 
     * @param mstnProjectCondition 项目条件
     * @return 结果
     */
    @Override
    public int updateMstnProjectCondition(MstnProjectCondition mstnProjectCondition)
    {
        mstnProjectCondition.setUpdateTime(DateUtils.getNowDate());
        return mstnProjectConditionMapper.updateMstnProjectCondition(mstnProjectCondition);
    }

    /**
     * 批量删除项目条件
     * 
     * @param projectConditionIds 需要删除的项目条件主键
     * @return 结果
     */
    @Override
    public int deleteMstnProjectConditionByProjectConditionIds(Long[] projectConditionIds)
    {
        return mstnProjectConditionMapper.deleteMstnProjectConditionByProjectConditionIds(projectConditionIds);
    }

    /**
     * 删除项目条件信息
     * 
     * @param projectConditionId 项目条件主键
     * @return 结果
     */
    @Override
    public int deleteMstnProjectConditionByProjectConditionId(Long projectConditionId)
    {
        return mstnProjectConditionMapper.deleteMstnProjectConditionByProjectConditionId(projectConditionId);
    }
}
